package com.jiangdong.craft.controller;


import com.jiangdong.craft.dto.ResponseDTO;
import com.jiangdong.craft.entity.Procedure;
import com.jiangdong.craft.service.ProcedureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/procedure")
@CrossOrigin
public class ProcedureController {

    @Autowired
    ProcedureService procedureService;

    @PostMapping("/add")
    public ResponseDTO add(Procedure procedure){
        return procedureService.add(procedure);
    }

    @PostMapping("/del")
    public ResponseDTO delById(@RequestParam("id") Integer id){
        return procedureService.delById(id);
    }


    /**
     * @param id 节点id
     * @param craftId 是否查询节点对应关系信息  传craftId查询 否则不查询
     * @return
     */
    @GetMapping("/query")
    public ResponseDTO query(@RequestParam("id") Integer id,
                             @RequestParam(value = "craftId",required = false) Integer craftId){
        return procedureService.query(id,craftId);
    }

}
